'''
Created on 17/08/2013

@author: hackma00100
'''

class HipnoArchivo(object):
    '''
    classdocs
    '''
    def __init__(self, fileName, modoRW):
        self.__abrirArchivo(fileName, modoRW)
    
    def __abrirArchivo(self, fileName, modoRW):
        self.file = open(fileName, modoRW)
        
    def writeFiles(self, **lineas):
        print 'mode' , self.file.mode
        self.file.writelines(lineas)
    
    def writeFile(self, line):
        print 'mode' , self.file.mode
        self.file.write(line)
        
    def readLine(self):
        line = self.file.readline()
        while line != "":
            if not line: break
            print line
            line = self.file.readline()
    
    def read(self, tamano):
        if tamano != None:
            line = self.file.read(tamano)
        else:
            line = self.file.read()        
        print line
        
    def readLines(self):
        lines = self.file.readlines()
        print lines
        for item in lines:
            print item
        
    def seek(self, offset, Whence):
        return self.file.seek(offset, Whence)   
    

    def tell(self):
        return self.file.tell()
    
    def truncate(self, tamano):
        self.file.truncate(tamano)
    
    def __del__(self):
        if not self.file.closed:
            self.file.close()
        else:
            print 'el archivo ', self.file.name, 'se encuentra cerrado'